home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-22 | 3.6 KB | 144 lines | [TEXT/CWIE] |
- // Release Version: $ ODF 2 $
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- //================================================================================
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- // ----- Framework Includes -----
- #ifndef FWABOUT_H
- #include "FWAbout.h" //::FW_About()
- #endif
-
- #ifndef SLMIXOS_H
- #include "SLMixOS.h" // FW_GetMainScreenBounds
- #endif
-
- //--- SOM library ------------------------------------------------
- #ifndef SOM_DevUniv_SFinance_xih
- #include "SFinance.xih" // DevUniv_SFinance SOM library
- #endif
-
- //==============================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment Calc
- #endif
-
- FW_DEFINE_AUTO(CCalcPart)
-
- //==============================================================================
- CCalcPart::CCalcPart(ODPart* odPart)
- : FW_CPart(odPart, FW_gInstance, kPartInfoID),
- fPresentation(NULL),
- fLoanAmount(0),
- fAnnualInterestPercent(0),
- fLoanYears(0),
- fMonthlyPayment(0),
- fSOMFinanceCalc(NULL)
- {
- }
-
- //--------------------------------------------------------------------------------
- CCalcPart::~CCalcPart()
- {
- delete fSOMFinanceCalc;
- }
-
- //--------------------------------------------------------------------------------
- void
- CCalcPart::Initialize(Environment* ev, ODStorageUnit* storageUnit, FW_Boolean fromStorage) // Override
- {
- FW_CPart::Initialize(ev, storageUnit, fromStorage);
- FW_CSelection* selection = NULL;
- const ODType kMainPresentation = "Apple:Presentation:Calc";
- fPresentation = this->RegisterPresentation(ev, kMainPresentation, true, selection);
- fSOMFinanceCalc = new DevUniv_SFinance;
- }
-
- //--------------------------------------------------------------------------------
- FW_CFrame*
- CCalcPart::NewFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation, FW_Boolean fromStorage) // Override
- {
- FW_UNUSED(fromStorage);
- return FW_NEW(CCalcFrame, (ev, odFrame, presentation, this));
- }
-
- //--------------------------------------------------------------------------------
- FW_CContent*
- CCalcPart::NewPartContent(Environment* ev)
- {
- FW_UNUSED(ev);
- return NULL;
- }
-
- //--------------------------------------------------------------------------------
- FW_Handled
- CCalcPart::DoAbout(Environment* ev)
- {
- ::FW_About(ev, this, kAbout);
-
- return FW_kHandled;
- }
-
- //-------------------------------------------------------------------
- CalcFloat
- CCalcPart::MyComputePayment(Environment* ev)
- {
- fMonthlyPayment = fSOMFinanceCalc->Payment(ev, fLoanAmount,
- fAnnualInterestPercent,
- fLoanYears);
- return fMonthlyPayment;
- }
-
- //-------------------------------------------------------------------
- void
- CCalcPart::MySetLoanAmount(CalcFloat borrowed)
- {
- fLoanAmount = borrowed;
- }
-
- //-------------------------------------------------------------------
- void
- CCalcPart::MySetAnnualInterestPercent(CalcFloat interest)
- {
- fAnnualInterestPercent = interest;
- }
-
- //-------------------------------------------------------------------
- void
- CCalcPart::MySetLoanYears(CalcFloat years)
- {
- fLoanYears = years;
- }
-
- //----------------------------------------------------------------------------------------
- FW_CWindow*
- CCalcPart::NewDocumentWindow(Environment* ev)
- {
- FW_CRect screenBounds;
- ::FW_GetMainScreenBounds(screenBounds);
- screenBounds.Inset(FW_IntToFixed(3), FW_IntToFixed(3));
-
- return new FW_CWindow(ev,
- this,
- FW_CPart::fgViewAsFrameToken,
- fPresentation,
- FW_CPoint(FW_IntToFixed(280), FW_IntToFixed(200)),
- screenBounds.TopLeft(),
- FW_kDocumentWindow);
- }
-